package com.example.todolist.mapper;
import com.example.todolist.entity.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

//user的所有控制接口
@Mapper
public interface UserMapper {
    //@Select("")

    @Insert("insert into user(userId,name,email,password)VALUES(#{userId},#{name},#{email},#{password})")
    int register(User user);

    @Update("update user set password=#{password} where userId=#{userId}")
    int updatePassword(Integer userId,String password);
    @Update("update user set email=#{email} where userId=#{userId}")
    int updateEmail(Integer userId,String email);

    @Select("select * from user")
    List<User> findAll();

    @Select("select * from user where name=#{name} AND password=#{password}")
    User login(String name, String password);

    @Select("select userId,name,email from user where userId=#{userId}")
    User findByUserId(Integer userId);

    @Select("select userId,name,email from user where name=#{name}")
    User findByName(String name);

}
